package com.reggie.service.impl;

import com.reggie.mapper.AddressBookMapper;
import com.reggie.pojo.AddressBook;
import com.reggie.service.AddressBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressBookServiceImpl implements AddressBookService {
    @Autowired
    AddressBookMapper addressBookMapper;

    @Override
    public List<AddressBook> findAll(Long userId) {
        List<AddressBook> addressBooks = addressBookMapper.findAll(userId);
        return addressBooks;
    }

    @Override
    public boolean add(AddressBook addressBook) {
        if (addressBookMapper.add(addressBook)==1) return true;
        return false;
    }

    @Override
    public boolean edit(AddressBook addressBook) {
        if (addressBookMapper.edit(addressBook)==1) return true;
        return false;
    }

    @Override
    public AddressBook find(Long id, Long userId, Integer isDefault) {
        AddressBook addressBook = addressBookMapper.find(id, userId, isDefault);
        return addressBook;
    }
}
